<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看运单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">
    <style>
        .thumb {width:220px;height: 200px}

    </style>
</head>
<body  >
<div class="layui-container">


    <form class="layui-form" id="check">
        <div class="layui-row">
            <div class="layui-col-md12">

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend id="checkElem"></legend>


                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 90px"  >运单号 </label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="ydh"   lay-verify="" placeholder="请输入"  class="layui-input" disabled="disabled" id="ydh">

                            <input   type="hidden" name="ydid"  >
                            <input   type="hidden" name="sfcz" value="1"  >
                            <input   type="hidden" name="sfscdd" value="1"  >
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 90px" >当前状态</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input name="ydzt" class="layui-input" lay-verify="" disabled="" id="ydzt" >
                                <input name="ydzt" type="hidden"  id="ydztvalue" >
                                <input name="bcid" type="hidden" class="layui-input" lay-verify="" disabled="" id="bcid">
                                </input>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 90px" >申请退回状态</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input name="sqthzt"  lay-verify="" class="layui-input" id="sqthzt" disabled="disabled">
                                </input>
                            </div>
                        </div>

                    </div>
                    <div class="layui-form-item">

                        <label class="layui-form-label"><span style="color: red;">*</span>申请原因</label>
                        <div class="layui-input-block" style="width: auto ;">
                            <textarea  style="height: auto" class="layui-textarea" name="sqyy"  id="sqyy" required  lay-verify="required" placeholder="请输入"   disabled="disabled"  ></textarea>
                        </div>

                    </div>
                    <div class="layui-form-item" style="position: relative; right:-40px">

                        <div class="layui-input-inline" style="width: 150px;">
                            <input name="errorpic" id="errorpic" type="hidden"  >
                            </input>
                            <div id="lookerrorpicBtn">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item" style="position: relative;left: 50%">
                        <label class="layui-form-label" style="width: 90px" disabled="disabled">申请人</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="sqr"   lay-verify="" placeholder="请输入" id="sqr" class="layui-input" disabled="disabled" >
                        </div>


                        <label class="layui-form-label" style="width: 90px">申请日期</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="sqrq" id="sqrq"   lay-verify="" placeholder="请输入"  class="layui-input" disabled="disabled" >
                        </div>

                    </div>



                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: auto">注意：运单一旦退回至某状态，其流转期间产生的相关数据均会删除，如，运单由“已发车”退回至“待调度”，则关联的“车牌号”将删除！</label>

                    </div>
                    <!--<div class="layui-form-item">-->
                    <!--<div class="layui-input-block" style="position: relative;left: 370px">-->

                </fieldset>

            </div>
        </div>

        <div class="layui-row">
            <div class="layui-col-md12">

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend id="checkElem2"> </legend>


                    <div class="layui-form-item">

                        <label class="layui-form-label"> 审核结果</label>
                        <div class="layui-inline">
                            <select name="shjg" required lay-verify="required"  >
                                <option value="同意">同意</option>
                                <option value="不同意">不同意</option>
                            </select>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 90px" >审核人</label>
                            <div class="layui-input-inline" style="width: 150px;" >
                                <input name="shr"  lay-verify="" class="layui-input layui-disabled"  id="shr"  disabled >
                                </input>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 90px" >审核日期</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input name="shrq"  lay-verify="" class="layui-input" id="shrq" >
                                </input>
                            </div>
                        </div>
                        <div class="layui-inline">
                           <button id="modiSub" class="layui-btn layui-btn-normal  "   lay-submit lay-filter="update"    >立即提交</button>
                        </div>

                    </div>





                    <!--<div class="layui-form-item">-->
                    <!--<div class="layui-input-block" style="position: relative;left: 370px">-->

                </fieldset>

            </div>
        </div>

    </form>
    <div id="checkHis">

    </div>
</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/tools.js"></script>
<script>
    layui.use(['table','form','layer','laydate','upload'],function () {

        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;
        var laydate = layui.laydate;


        $("#modiInfo").on('click',function(){
            $("#huowu,#hwsl,#yunfei,#gls,#ydj").removeClass("layui-disabled");
            $("#huowu,#hwsl,#yunfei,#gls,#ydj").removeAttr("disabled",true);

            $("#modiSub").removeClass("layui-btn-disabled");
            $("#modiSub").removeAttr("disabled");

            $("#modiInfo").addClass("layui-btn-disabled");
            $("#modiInfo").attr("disabled",true);
        });
//填充待审核的运单信息
//         console.log($("#ydztvalue").val())
        if($("#ydztvalue").val() == "审核中"){

            $.ajax({
                url: contextPath+"/error/"+$("#ydh").val(),
                type: "GET",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                success: function(res) {
                    // console.log(res);
                    var data = res.list[0];
                    // console.log(res.list);

                    switch(data.sqthzt.toString().split('_')[0]){
                        case "订单":
                            $("#checkElem").html("车辆待调度退回");
                            $("#checkElem2").html("车辆待调度审核");
                            break;
                        case "调度":
                            $("#checkElem").html("车辆调度退回");
                            $("#checkElem2").html("车辆调度审核");
                            break;
                        case "登记":
                            $("#checkElem").html("回车登记退回");
                            $("#checkElem2").html("回车登记审核");
                            break;
                        case "报账":
                            $("#checkElem").html("回车报账退回");
                            $("#checkElem2").html("回车报账审核");
                            break;
                        case "快捷":
                            $("#checkElem").html("快捷运单退回");
                            $("#checkElem2").html("快捷运单审核");
                            break;
                    }
                    $("#sqthzt").val(data.sqthzt.toString().split('_')[1]);
                    $("#sqyy").val(data.sqyy);
                    $("#sqr").val(data.sqr);
                    $("#sqrq").val(data.sqrq);
                    $("#bcid").val(data.bcid);
                    $("#ydzt").val(data.ydzt);
                    $("#errorpic").val(data.errorpic);

                    divphoto($,layer,"errorpic");
                    lookFile($,layer,"errorpic");
                    download($,layer,"errorpic");
                }
            })

            // 添加历史审核信息
            $.ajax({
                url: contextPath+"/error/"+$("#ydh").val(),
                type: "GET",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                success: function(res) {
                    var checked = res.list.slice(1);
                    // console.log(checked);
                    var checktitle = "<fieldset class=\"layui-elem-field layui-field-title\"><legend   style='height:2px;color:black'>退回历史记录</legend></fieldset>";
                    $("#checkHis").append(checktitle);
                    $.each(checked,function (i,e) {


                        switch(e.sqthzt.toString().split('_')[0]){
                            case "订单":
                                e.title1 = ("车辆待调度退回");
                                e.title2 = ("车辆待调度审核");
                                break;
                            case "调度":
                                e.title1 = ("车辆调度退回");
                                e.title2 = ("车辆调度审核");
                                break;
                            case "登记":
                                e.title1 =("回车登记退回");
                                e.title2 =("回车登记审核");
                                break;
                            case "报账":
                                e.title1 =("回车报账退回");
                                e.title2 =("回车报账审核");
                                break;
                            case "快捷":
                                e.title1 =("快捷运单退回");
                                e.title2 =("快捷运单审核");
                                break;
                        }

                        var oneError =
                            "   <div class=\"layui-row\">\n" +
                            "            <div class=\"layui-col-md12\">\n" +
                            "\n" +
                            "                <fieldset class=\"layui-elem-field\" style=\"margin-top: 20px;\">\n" +
                            "                    <legend>"+e.title1+"</legend>\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: 90px\"  >运单号 </label>\n" +
                            "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                            <input   type=\"text\" name=\"ydh\"   lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" disabled=\"disabled\" value="+ e.ydh +" >\n" +
                            "\n" +
                            "                            <input   type=\"hidden\" name=\"ydid\"  >\n" +
                            "                            <input   type=\"hidden\" name=\"sfcz\" value=\"1\"  >\n" +
                            "                            <input   type=\"hidden\" name=\"sfscdd\" value=\"1\"  >\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >当前状态</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"ydzt\" class=\"layui-input\" lay-verify=\"\" disabled=\"\" value="+ e.ydzt+" >\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >申请退回状态</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"sqthzt\"  lay-verify=\"\" class=\"layui-input\" disabled=\"\"value=" + e.sqthzt.toString().split('_')[1]+ ">\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "\n" +
                            "                        <label class=\"layui-form-label\"><span style=\"color: red;\">*</span>申请原因</label>\n" +
                            "                        <div class=\"layui-input-block\" style=\"width: auto ;\">\n" +
                            "                            <textarea  style=\"height: auto\" class=\"layui-textarea\" name=\"sqyy\"  required  lay-verify=\"required\" disabled=\"\" placeholder=\"请输入\"> "+ e.sqyy+"</textarea>\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\" style=\"position: relative; left: 50%\">\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: 90px\" >申请人</label>\n" +
                            "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                            <input   type=\"text\" name=\"sqr\"   lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" value=" + e.sqr+" disabled=\"disabled\">\n" +
                            "                        </div>\n" +
                            "\n" +
                            "\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: 90px\">申请日期</label>\n" +
                            "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                            <input   type=\"text\" name=\"sqrq\"     lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" disabled=\"disabled\" value="+e.sqrq+" >\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: auto\">注意：运单一旦退回至某状态，其流转期间产生的相关数据均会删除，如，运单由“已发车”退回至“待调度”，则关联的“车牌号”将删除！</label>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "                    <!--<div class=\"layui-form-item\">-->\n" +
                            "                    <!--<div class=\"layui-input-block\" style=\"position: relative;left: 370px\">-->\n" +
                            "\n" +
                            "                </fieldset>\n" +
                            "\n" +
                            "            </div>\n" +
                            "        </div>\n" +
                            "        <div class=\"layui-row\">\n" +
                            "            <div class=\"layui-col-md12\">\n" +
                            "\n" +
                            "                <fieldset class=\"layui-elem-field\" style=\"margin-top: 20px;\">\n" +
                            "                    <legend>"+e.title2+"</legend>\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "\n" +
                            "                        <label class=\"layui-form-label\"> 审核结果</label>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <input name=\"shjg\" class=\"layui-input\" required lay-verify=\"required\"  value='"+ e.shjg +"'>\n" +
                            "\n" +
                            "                            </input>\n" +
                            "                        </div>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >审核人</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"shr\"  lay-verify=\"\" class=\"layui-input\"  value='"+e.shr+"'>\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >审核日期</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"shrq\"    lay-verify=\"\" class=\"layui-input\"  value='"+ e.shrq+"'>\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "\n" +
                            "                </fieldset>\n" +
                            "\n" +
                            "            </div>\n" +
                            "        </div>";

                        $("#checkHis").append(oneError);


                    });



                }
            });
        }else{
            $("#check").css("display","none");
// 添加历史审核信息

            $.ajax({
                url: contextPath+"/error/"+$("#ydh").val(),
                type: "GET",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                success: function(res) {
                    var checked = res.list.slice(1);
                    var checktitle = "<fieldset class=\"layui-elem-field layui-field-title\"><legend   style='height:2px;color:black'>退回历史记录</legend></fieldset>";
                    $("#checkHis").append(checktitle);
                    // console.log(checked);
                    $.each(res.list,function (i,e) {


                        switch(e.sqthzt.toString().split('_')[0]){
                            case "订单":
                                e.title1 = ("车辆待调度退回");
                                e.title2 = ("车辆待调度审核");
                                break;
                            case "调度":
                                e.title1 = ("车辆调度退回");
                                e.title2 = ("车辆调度审核");
                                break;
                            case "登记":
                                e.title1 =("回车登记退回");
                                e.title2 =("回车登记审核");
                                break;
                            case "报账":
                                e.title1 =("回车报账退回");
                                e.title2 =("回车报账审核");
                                break;
                            case "快捷":
                                e.title1 =("快捷运单退回");
                                e.title2 =("快捷运单审核");
                                break;
                        }

                        var oneError =
                            "   <div class=\"layui-row\">\n" +
                            "            <div class=\"layui-col-md12\">\n" +
                            "\n" +
                            "                <fieldset class=\"layui-elem-field\" style=\"margin-top: 20px;\">\n" +
                            "                    <legend>"+e.title1+"</legend>\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: 90px\"  >运单号 </label>\n" +
                            "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                            <input   type=\"text\" name=\"ydh\"   lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" disabled=\"disabled\" value="+ e.ydh +" >\n" +
                            "\n" +
                            "                            <input   type=\"hidden\" name=\"ydid\"  >\n" +
                            "                            <input   type=\"hidden\" name=\"sfcz\" value=\"1\"  >\n" +
                            "                            <input   type=\"hidden\" name=\"sfscdd\" value=\"1\"  >\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >当前状态</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"ydzt\" class=\"layui-input\" lay-verify=\"\" disabled=\"\" value="+ e.ydzt+" >\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >申请退回状态</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"sqthzt\"  lay-verify=\"\" class=\"layui-input\" disabled=\"\"value=" + e.sqthzt.toString().split('_')[1]+ ">\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "\n" +
                            "                        <label class=\"layui-form-label\"><span style=\"color: red;\">*</span>申请原因</label>\n" +
                            "                        <div class=\"layui-input-block\" style=\"width: auto ;\">\n" +
                            "                            <textarea  style=\"height: auto\" class=\"layui-textarea\" name=\"sqyy\"  required  lay-verify=\"required\" disabled=\"\" placeholder=\"请输入\"> "+ e.sqyy+"</textarea>\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\" style=\"position: relative; left: 50%\">\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: 90px\" >申请人</label>\n" +
                            "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                            <input   type=\"text\" name=\"sqr\"   lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" value=" + e.sqr+" disabled=\"disabled\">\n" +
                            "                        </div>\n" +
                            "\n" +
                            "\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: 90px\">申请日期</label>\n" +
                            "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                            <input   type=\"text\" name=\"sqrq\"     lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" disabled=\"disabled\" value="+e.sqrq+" >\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "                        <label class=\"layui-form-label\" style=\"width: auto\">注意：运单一旦退回至某状态，其流转期间产生的相关数据均会删除，如，运单由“已发车”退回至“待调度”，则关联的“车牌号”将删除！</label>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "                    <!--<div class=\"layui-form-item\">-->\n" +
                            "                    <!--<div class=\"layui-input-block\" style=\"position: relative;left: 370px\">-->\n" +
                            "\n" +
                            "                </fieldset>\n" +
                            "\n" +
                            "            </div>\n" +
                            "        </div>\n" +
                            "        <div class=\"layui-row\">\n" +
                            "            <div class=\"layui-col-md12\">\n" +
                            "\n" +
                            "                <fieldset class=\"layui-elem-field\" style=\"margin-top: 20px;\">\n" +
                            "                    <legend>"+e.title2+"</legend>\n" +
                            "\n" +
                            "\n" +
                            "                    <div class=\"layui-form-item\">\n" +
                            "\n" +
                            "                        <label class=\"layui-form-label\"> 审核结果</label>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <input name=\"shjg\" class=\"layui-input\" required lay-verify=\"required\"  value='"+ e.shjg +"'>\n" +
                            "\n" +
                            "                            </input>\n" +
                            "                        </div>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >审核人</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"shr\"  lay-verify=\"\" class=\"layui-input\"  value='"+e.shr+"'>\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "                        <div class=\"layui-inline\">\n" +
                            "                            <label class=\"layui-form-label\" style=\"width: 90px\" >审核日期</label>\n" +
                            "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                            "                                <input name=\"shrq\"    lay-verify=\"\" class=\"layui-input\"  value='"+ e.shrq+"'>\n" +
                            "                                </input>\n" +
                            "                            </div>\n" +
                            "                        </div>\n" +
                            "\n" +
                            "                    </div>\n" +
                            "\n" +
                            "                </fieldset>\n" +
                            "\n" +
                            "            </div>\n" +
                            "        </div>";

                        $("#checkHis").append(oneError);


                    });



                }
            });
        }



        laydate.render({
            elem: '#shrq' //指定元素
            ,theme:'#0099FF'
            ,value: getFormatDate()
            ,type: 'date'
            ,format:'yyyy-MM-dd'
        });





        $.ajax({
            url: contextPath+"/currentUser",
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(res) {
                currentUser = res.yhm;
                // console.log(res);
                $("#shr").val(currentUser);
            }
        });


        form.on('submit(update)', function(data){
            // console.log(JSON.stringify(data.field) );
            $("input").css("border","");
            $.ajax({
                url: contextPath+"/error",
                type: "PUT",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    updateSuccess($,layer,res)
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>